/**
 * Created by Administrator on 2018/9/20.
 */
//window.onload = function(){
$.ajax({
    url:'https://www.pooai.cn/wx/frontend/web/index.php?r=marketing%2Fsharereb%2Fapiconfall/',
    data:{abstrUrl:location.href.split('#')[0]},
    type:'post',
    success:function(data){

        //获取验证数据，进行判断
        var result = eval('('+data+')');
        if(result && result.code == 200){
            wx.config({
                debug: false,
                appId: result.signPackage['appId'],
                timestamp:result.signPackage['timestamp'],
                nonceStr: result.signPackage['nonceStr'],
                signature: result.signPackage['signature'],
                jsApiList: result.signPackage['jsApiList']
            });
        }
        //分享操作
        wx.ready(function () {
            // 2.2 监听“分享到朋友圈”按钮点击、自定义分享内容及分享结果接口
            wx.onMenuShareTimeline({
                title: '小普商城', // 分享标题
                link: "https://www.pooai.cn/wx/frontend/web/index.php?r=marketing/sharereb/goindex",
                imgUrl: 'https://www.pooai.cn/wx/frontend/web/upload/fenxiang.png',
                trigger: function (res) {
                    //alert('用户点击分享到朋友圈');
                },
                success: function (res) {
                    //alert('已分享了');
                },
                cancel: function (res) {
                    //alert('已取消');
                },
                fail: function (res) {
                    alert(JSON.stringify(res));
                }
            });
            wx.onMenuShareAppMessage({
                title: '小普商城', // 分享标题
                //link: 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx5dee5a1c01f37b68&redirect_uri=http%3A%2F%2Fwww.pooai.cn%2Fwx%2Ffrontend%2Fweb%2Findex.php%3Fr%3Dsite%252Fsite%252Fdetail%26qcode%3Dcbfe7330-e0a6-11e7-85e3-a3ad0180d146&response_type=code&scope=snsapi_userinfo&state=authorize#wechat_redirect', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                link: "https://www.pooai.cn/wx/frontend/web/index.php?r=marketing/sharereb/goindex",
                desc: '成功购买小普智能马桶，分享二维码给好友，通过您的二维码购买的好友，将助你获得商品10%返利。', // 分享描述
                imgUrl:' https://www.pooai.cn/wx/frontend/web/upload/fenxiang.png',
                type: '', // 分享类型,music、video或link，不填默认为link
                dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
                success: function () {

                },
                cancel: function () {

                }
            });
        })



    }
})


//}